package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.IntegralDetail;
import com.zy.pojo.query.bs.IntegralDetailQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.IntegralDetailService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

@RequestMapping({"bs/integralDetail","m/bs/integralDetail"})
@Controller
public class IntegralDetailController extends BaseController {

	@Autowired
	private IntegralDetailService integralDetailService;

	/**
	 * 分页
 	 * 
 	 * @param integralDetailQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageIntegralDetail")
	@ResponseBody
	public PageVo pageIntegralDetail(IntegralDetailQuery integralDetailQuery, Integer start, Integer limit) {
		return this.integralDetailService.pageIntegralDetail(integralDetailQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param integralDetail
	 * @return
	 */
	@RequestMapping(value = "saveIntegralDetail", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveIntegralDetail(IntegralDetail integralDetail) {
		try {
			this.integralDetailService.saveIntegralDetail(integralDetail);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param integralDetail
	 * @return
	 */
	@RequestMapping(value = "updateIntegralDetail", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateIntegralDetail(IntegralDetail integralDetail) {
		try {
			this.integralDetailService.updateIntegralDetail(integralDetail);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeIntegralDetail", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeIntegralDetail(long id) {
		try {
			this.integralDetailService.removeIntegralDetail(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.integralDetailService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping(value = "getIntegralDetailList", method = RequestMethod.GET)
	@ResponseBody
	public PageVo getIntegralDetailList(Integer start, Integer limit) {
            return integralDetailService.appList(this.getCurrentUser().getId(),start,limit);
	}
	@RequestMapping(value = "getIntegralDetailInfo")
	@ResponseBody
	public ResultVo getIntegralDetailInfo(long id) {
		try {
			return ResultUtil.success(	this.integralDetailService.getByPrimaryKey(id));
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}


}